package com.msg;

import java.util.HashMap;
import java.util.Iterator;

/**
 * @file_name ITemplateManager.java
 * @author honny.huang
 * @date 2011-10-25
 */
public class ITemplateManager
{
    
    /**
     * <消息、邮件模板处理>
     * <功能详细描述>
     * @param tempStr
     * @param parm
     * @return [参数说明]
     * 
     * @return String [返回类型说明]
     * @exception throws [违例类型] [违例说明]
     * @see [类、类#方法、类#成员]
     */
    public static String builder(String tempStr,HashMap<String, String> parm){
        Iterator<String> it = parm.keySet().iterator();
        while (it.hasNext()) {
         String key=it.next().toString();
         String value=String.valueOf(parm.get(key));
         tempStr=tempStr.replace("["+key+"]", value);
        }
        return tempStr;
    }
    
    public static void main(String[] args){
        HashMap map = new HashMap();
        map.put("111", "a");
        map.put("222", "b");
        map.put("333", "c");
        map.put("444", "d");
        System.out.println(builder("eeee[222]eeeee[111]wwwwwwwww[333]=========[444][444][111]",map));
        // 调用事例
        System.out.print(ITemplateManager.builder(TemplateManager.get("XXX"), map));
    }
}
